package com.app.dprocessone.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import androidx.annotation.Nullable;
import android.util.Log;

import com.app.dprocessone.ClientInterface;
import com.app.dprocessone.DaemonProcessOneAidl;

public class DaemonProcessOneService extends Service {

    private static final String TAG = DaemonProcessOneService.class.getSimpleName();

    private ClientInterface clientInterface;

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate: Process -> " + Process.myPid());
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }


    @Override
    public boolean onUnbind(Intent intent) {
        return super.onUnbind(intent);
    }

    DaemonProcessOneAidl.Stub mBinder = new DaemonProcessOneAidl.Stub() {

        @Override
        public boolean open() throws RemoteException {
            Log.i(TAG, "open: ");
            return false;
        }

        @Override
        public boolean close() throws RemoteException {

            return false;
        }

        @Override
        public void registerClient(ClientInterface cb) throws RemoteException {
            clientInterface = cb;
        }
    };

}
